home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 February: Tool Chest / Dev.CD Feb 95 / Dev.CD Feb 95.toast / Tool Chest / QuickDraw GX / QuickDraw GX Info / QuickDraw GX Interfaces / Interfaces & Libraries / graphics libraries / graphics toolbox library.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-30  |  1.1 KB  |  49 lines  |  [TEXT/MPS ]

  1. #include <Memory.h>
  2. #include <Resources.h>
  3.  
  4. #include "font routines.h"
  5. #include "graphics toolbox library.h"
  6.  
  7. #define segmentLoaderTrashesResLoadState
  8.  
  9. #ifdef segmentLoaderTrashesResLoadState
  10.     #define SETRESLOAD(load)    SetResLoad(load)
  11. #else
  12.     #define SETRESLOAD(load)
  13. #endif
  14.  
  15. long AddResFileFonts(short resFileID, gxFont** fonts)
  16. {
  17.     long i, count;
  18.     long validFonts = 0;
  19.     char resLoadState = *(char*)0xa5e;
  20.     short oldResFile = CurResFile();
  21.  
  22.     UseResFile(resFileID);
  23.     count = Count1Resources('sfnt');
  24.     if (fonts)
  25.         SetHandleSize((Handle)fonts, count * sizeof(gxFont));
  26.     SetResLoad(false);
  27.  
  28.     for (i = 1; i <= count; i++)
  29.     {   Handle sfnt;
  30.  
  31.         SETRESLOAD(false);
  32.         sfnt = Get1IndResource('sfnt', i);
  33.         if (sfnt && !ResError())
  34.         {   gxFont fontID = GXNewFont(gxResourceFontStorage, sfnt, 0);
  35.             if (fonts)
  36.                 (*fonts)[validFonts] = fontID;
  37.             validFonts++;
  38.         }
  39.     }
  40.  
  41.     SetResLoad(resLoadState);
  42.     if (fonts && validFonts != count)
  43.         SetHandleSize((Handle)fonts, validFonts * sizeof(gxFont));
  44.     UseResFile(oldResFile);
  45.  
  46.     return validFonts;
  47. }
  48.  
  49.